测试链接：https://leetcode.cn/problems/minimum-size-subarray-sum/description/
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int n = nums.size();
        int ans = INT_MAX;
        for(int l = 0, r = 0, sum = 0; r < n;)
        {
            while(r < n && ((sum + nums[r]) < target))
            {
                sum += nums[r];
                r++;
            }
            if(r >= n) break; //防止一马平川走到n
            
            ans = min(ans, r - l + 1);

            sum -= nums[l];
            l++;
        }
        return ans == INT_MAX ? 0 : ans;
    }
};